/**
 * 
 */
package com.study.thread;

/**
 * @author Administrator
 * @date 2019年6月17日
 */
public class JoinThreadDemo {

	public static void main(String[] args) {
		JoinThread joinThread = new JoinThread();
		Thread t1 = new Thread(joinThread);
		t1.start();
		try {
			//main线程变为等待状态，等t1线程执行完成之后才能执行join方法。
			t1.join();
		} catch (Exception e) {

		}
		for (int i = 0; i < 3; i++) {
			System.out.println("main ---i:" + i);
		}
	}

}

class JoinThread implements Runnable {

	public void run() {
		for (int i = 0; i < 3; i++) {
			System.out.println(Thread.currentThread().getName() + "---i:" + i);
		}
	}
}